package com.jsoft.dto;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.List;

/**
 * Date: 16.08.13
 * Time: 0:11
 */

public class UserDto extends PersonDto {
    private String login;
    private String password;
    private String sig;
    private List<SectorDto> sectorList;

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setSig(String str) {
        this.sig = generateSig(str);
    }

    public String getSig() {
        return sig;
    }

    public List<SectorDto> getSectorList() {
        return sectorList;
    }

    public void setSectorList(List<SectorDto> sectorList) {
        this.sectorList = sectorList;
    }

    private String generateSig(String str) {
        MessageDigest m;
        String s = "";
        try {
            m = MessageDigest.getInstance("MD5");
            m.update(str.getBytes(), 0, str.length());
            s = new BigInteger(1, m.digest()).toString(16);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return s;
    }
}
